package com.anjubao.parking.municipal.parkinglot.controller;

import com.anjubao.parking.municipal.common.dto.ApiResult;
import com.anjubao.parking.municipal.parkinglot.dto.DeviceWarningDto;
import com.anjubao.parking.municipal.parkinglot.service.DeviceService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备日志基本api
 * @author anjubao.com
 *
 */


@RestController
@RequestMapping("/parking-lot-device")
@Api(value="ParkingLotDevice模块",tags = {"设备日志接口"})
public class DeviceController {

    private static final Logger logger = LoggerFactory.getLogger(DeviceController.class);

    @Autowired
    private DeviceService deviceService;

    @GetMapping("")
    @ApiOperation(value = "最近100条告警列表")
    @ApiResponses(value = {
            @ApiResponse(code = 5000,message = "操作失败")
    })
    /**
     * 查询
     *
     * @return
     */
    public ApiResult<List<DeviceWarningDto>> getWarningList() {
        logger.info("查询最近100条告警列表 {} ");
        Page<DeviceWarningDto> page=new Page<>();
        page.setSize(100);
        page.setCurrent(1);
        IPage<DeviceWarningDto> resDtos=deviceService.getWarningList(page);
        return ApiResult.success(resDtos.getRecords(), (int) resDtos.getTotal());
    }


















}
